package com.kx.ssm.pojo;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.util.StringUtils;

import java.util.Date;

public class User implements CheckNull{


  private Long id;
  private String username;
  @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)//不能直接使用@JsonIgnore,会导致接收参数
  private String password;
  @JsonIgnore//忽略掉,不能返回给用户
  private String passwordsalt;//密码的盐
  private Long age;
  private String address;
  @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
  private Date birthday;
  private Long status;
  private String picurl;


  @Override
  public boolean isEmpty() {
    return StringUtils.isEmpty(username)||StringUtils.isEmpty(password)||StringUtils.isEmpty(address)||birthday==null;
  }

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getUsername() {
    return username;
  }

  public void setUsername(String username) {
    this.username = username;
  }

  public String getPassword() {
    return password;
  }

  public void setPassword(String password) {
    this.password = password;
  }

  public String getPasswordsalt() {
    return passwordsalt;
  }

  public void setPasswordsalt(String passwordsalt) {
    this.passwordsalt = passwordsalt;
  }

  public Long getAge() {
    return age;
  }

  public void setAge(Long age) {
    this.age = age;
  }

  public String getAddress() {
    return address;
  }

  public void setAddress(String address) {
    this.address = address;
  }

  public Date getBirthday() {
    return birthday;
  }

  public void setBirthday(Date birthday) {
    this.birthday = birthday;
  }

  public Long getStatus() {
    return status;
  }

  public void setStatus(Long status) {
    this.status = status;
  }

  public String getPicurl() {
    return picurl;
  }

  public void setPicurl(String picurl) {
    this.picurl = picurl;
  }

  @Override
  public String toString() {
    return "User{" +
            "id=" + id +
            ", username='" + username + '\'' +
            ", password='" + password + '\'' +
            ", passwordsalt='" + passwordsalt + '\'' +
            ", age=" + age +
            ", address='" + address + '\'' +
            ", birthday=" + birthday +
            ", status=" + status +
            ", picurl='" + picurl + '\'' +
            '}';
  }
}
